<layout name='../Layout/frame_main' />

<body>
<div class="container-fluid">
	<div class="row-fluid">
		<div class="span12">
			<div class="page-header">
				<h2>
					大分类列表  
					 <small>共{$count}条数据</small>
					 <br/><a href="#myAdd" class="btn btn-small btn-primary" data-toggle="modal">添加分类</a>
				</h2>
			</div>
			<?php 
			if(count($list)==0)
			{
				echo '<h4>暂时没有数据</h4>';
			}
			else
			{
			?>
			<table class="table table-bordered table-hover table-condensed">
				<thead>
					<tr>
						<th>
							编号
						</th>
						<th>
							名称
						</th><th>
							有效性
						</th>
						
						<th>
							排列序号
						</th>
						<th>
							删除
						</th>
					</tr>
				</thead>
				<tbody>
					<volist name="list" id="vo">
					<tr >
						<td>
							{$vo.type_id}
						</td>
						<td>
							{$vo.type_name}
						</td>
						<td>
							<label class="checkbox">
								<?php
								if($vo["type_valid"]==1)
									echo "<input type='checkbox' checked /><span>有效</span>";
								else 
									echo "<input type='checkbox' /><span>已下架</span>";
								 ?>
						</label>							
						</td>
						<td>
							<span class="btn  btn-mini move" >上移<i class="icon-arrow-up"></i>
               </span><span class="label label-info">{$i+$skip}</span><span class="label1 hide">{$vo.type_seq}</span><span class="btn  btn-mini move" >下移<i class="icon-arrow-down"></i>
               </span>
						</td>
						
						<td>
						<a data-toggle="modal" class="btn btn-danger" role="button" href="#myModal{$i}">删除</a>
						</td>
							<form id="form{$i}" action="__URL__/del/type_id/{$vo.type_id}" method='get'>
							  <div id="myModal{$i}" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
							    <div class="modal-header">
							      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
							      <h3 id="myModalLabel">系统确认</h3>
							    </div>
							    <div class="modal-body">
							      <p>确定要删除分类名称为【{$vo.type_name}】，编号号为【{$vo.type_id}】 的所有大分类吗？数据删除将导致无法恢复！点击【关闭】退出继续操作，点击【确认删除】进行删除数据操作。</p>
							    </div>
							    <div class="modal-footer">
							      <button class="btn" data-dismiss="modal" aria-hidden="true" id="clbtn{$vo.rownum}">关闭</button>
							      <button class="btn btn-danger" type="submit">确认删除</button>
							    </div>
							  </div>
							</form>
					</tr>
				</volist>
				</tbody>
			</table>
			<div class="pagination pagination-centered">
				<ul>
					<li>{$page}</li>
				</ul>
			</div>
			<?php } ?>
		</div>
	</div>
	<div class="row-fluid">
		<div class="span12">
		</div>
	</div>
</div>

<form id="formadd" action="__URL__/adt" method='post'>
							  <div id="myAdd" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
								    <div class="modal-header">
								      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
								      <h3 id="myModalLabel">添加分类</h3>
								    </div>
								    <div class="modal-body">
									    <div class="container-fluid">
											<div class="row-fluid">
												<div class="span12">
													<div class="row-fluid">
	<div class="span8">
		<span class='cn_name'></span><span class='cn_val'>

		</span><br/>	

		<span class='cn_name'>分类名称&nbsp; </span><span class='cn_val'><input type="text" name="type_name"  value='' /></span><br/>
		<input type="hidden" name="type_seq"  value='{$count}' /></span>
		<input type="hidden" name="type_valid"  value='0' /></span>
	</div>
													</div>
												</div>
											</div>
										</div>
								    </div>
								    <div class="modal-footer">
								      <button class="btn" data-dismiss="modal" aria-hidden="true" id="clbtn">关闭</button>
								      <button class="btn btn-primary" type="submit">确认</button>
								    </div>
							  </div>
							</form>

</body>

<script type="text/javascript">
	$('input:checkbox').click(function(){
		var v=$.trim($(this).parent().parent().parent().children(':first').text());
		var tc=this;
		$.post(
			"__URL__/check/",
			'pvalue='+v+'&data='+(this.checked?1:0),
			function(data){
				if(data=='OK')
				{
					$(tc).next().text(!tc.checked?'已下架':'有效');
					alert('处理成功！');
					location.reload();
				}
				else
				{
					alert('处理失败！');
					tc.checked=!tc.checked;
				}
			});
	});
		$('.move').click(function(){
		var v=$.trim($(this).parent().parent().children(':first').text());
		var w=$.trim($(this).parent().parent().children(':eq(3)').children("span.label1").text());
		var tc=this;
		$.post(
			"__URL__/move/",
			'type_id='+v+'&data='+w+'&moveup='+(this.innerHTML.indexOf("up")==-1?"0":"1"),
			function(data){
				if(data=='OK')
				{
					location.reload();
				}
				else
				{
					if(data=="Wrong")
						alert("处理失败！");
					else alert(data);
				}
			});
	});
</script>